package com.hotSpot.chapter.two.four;

import java.util.ArrayList;
import java.util.List;
/**
 * 
 * @author wangjunjie
 * VM arguments参数配置:
 * -Xms20M -Xmx20M -XX:+HeapDumpOnOutOfMemoryError
 * 通常来说，只要你设置了如下所示的 
 * JVM 参数：-XX:+HeapDumpOnOutOfMemoryErrorJVM 
 * 就会在发生内存泄露时抓拍下当时的内存状态，也就是我们想要的堆转储文件。
 *
 */
public class HeapOOM {

	static class OOMObject{
		
		private Person person;
	    
		 public Person getPerson() {
			return person;
		}

		public void setPerson(Person person) {
			this.person = person;
		}
		
		 OOMObject(){}
		 
		 OOMObject(Person person){
			 this.person = person;
			 
		 }
	 }
	 
	 static class Person{
		 private String name;
		 private Integer age;
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public Integer getAge() {
			return age;
		}
		public void setAge(Integer age) {
			this.age = age;
		}
	 }
    
    public static void main(String[] args){
    	List<OOMObject> list = new ArrayList<OOMObject>();
		while(true){
			list.add(new OOMObject(new Person()));
		}
    }
	 
}
